package org.lq.dlz.dao.impl;

import java.sql.SQLException;

import org.apache.commons.dbutils.QueryRunner;
import org.lq.dlz.dao.CouponDao;
import org.lq.dlz.entity.Coupon;
import org.lq.dlz.util.JDBCUtils;
/**
 * 购物券模块
 * @author xie
 *
 */
public class CouponDaoImpl implements CouponDao{
	 private QueryRunner qr = new QueryRunner(JDBCUtils.getDataSource());
	@Override
	public int addCoupon(Coupon coupon) {
		String sql="INSERT INTO `dlz_shopping`.`coupon`( `type`, `name`, `count`, `amount`, `min_point`, `start_time`, `publish_count`, `end_time`, `use_type`, `note`, `code`, `use_count`, `receive_count`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
		
		try {
			return qr.update(sql, coupon.getType(),coupon.getName(),coupon.getAmount(),coupon.getMin_point(),coupon.getStart_time(),coupon.getPublish_count(),coupon.getEnd_time(),coupon.getUse_type(),coupon.getNote(),coupon.getCode(),coupon.getUse_count(),coupon.getReceive_count());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

}
